package com.net.oil.base;
/*
 * Created by lch on 2018/2/21 0021.
 */

import android.os.Bundle;
import androidx.annotation.Nullable;;
import androidx.fragment.app.Fragment;

import com.net.oil.R;
import com.net.oil.widget.LoadingDialog;

public class BaseFragment<T extends BasePresenter> extends Fragment {
    protected T presenter;
    public LoadingDialog progressDialog;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (presenter != null) {
            presenter.detachView();
        }
    }

    public LoadingDialog showProgressDialog() {
        progressDialog = new LoadingDialog(getContext(), R.style.CustomDialog);
        progressDialog.setMessage("加载中");
        progressDialog.show();
        return progressDialog;
    }


    public LoadingDialog showProgressDialog(CharSequence message) {
        progressDialog = new LoadingDialog(getContext(), R.style.CustomDialog);
        progressDialog.setMessage(message);
        progressDialog.show();
        return progressDialog;
    }

    public void dismissProgressDialog() {
        if (progressDialog != null && progressDialog.isShowing()) {
            progressDialog.dismiss();
        }
    }
}
